package com.jie.scrollviewwithlistview;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ListView lv;
    private List<String> datas;
    private Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context = this;
        initDatas();
        initView();
    }

    private void initDatas() {
        datas = new ArrayList<>();
        datas.add("默认情况下");
        datas.add("recycler自定义layoutManager");



    }

    private void initView() {
        lv = (ListView) findViewById(R.id.lv);
        MyAdapter adapter = new MyAdapter(datas,context);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        startActivity(new Intent(MainActivity.this, CommontActivity.class));
                        break;
                    case 1:
                        startActivity(new Intent(MainActivity.this, ReActivity.class));
                        break;

                }
            }
        });
    }


}
